Skip to content

[http] sanitise URL options before use them#22186

Merged
linev merged 6 commits into
root-project:masterfrom
linev:http_sanity_arg
May 20, 2026
Merged

[http] sanitise URL options before use them#22186
linev merged 6 commits into
root-project:masterfrom
linev:http_sanity_arg

Conversation

@linev

@linev linev commented May 8, 2026

Copy link
Copy Markdown
Member

URL syntax allow to provide different special symbols using %12%20 symbols.
Also some situations un-escaped quotes can make a problems.
Therefore cleanup arguments from URL string adding C escape symbols.
Discard URL arguments longer than 1K

Use it in exe.json and cmd.json - main place where arguments which are coming via URL
are formatted for ProcessLine.

Add sophisticated check in cmd.json processing. One need to check quotes in argument and
in command definition around argument. If none exists - only simple numeric values can be injected
without quotes. Avoid double quotes on both side of argument placeholder.

Provide special flag to enable processing of post data in the exe.json, off by default.

Provide testing for the main requests processing in the sniffer.
This emulates response of THttpServer with same kind of http requests.

@linev linev requested review from dpiparo and jblomer May 8, 2026 09:16
@linev linev self-assigned this May 8, 2026
@github-actions

github-actions Bot commented May 8, 2026

Copy link
Copy Markdown

Test Results

    22 files      22 suites   3d 10h 33m 7s ⏱️
 3 856 tests  3 856 ✅ 0 💤 0 ❌
77 054 runs  77 054 ✅ 0 💤 0 ❌

Results for commit ab58efa.

♻️ This comment has been updated with latest results.

@dpiparo dpiparo changed the title [http] sanity URL options before use them [http] sanitise URL options before use them May 8, 2026
Comment thread net/httpsniff/src/TRootSnifferFull.cxx Outdated

@silverweed silverweed left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general I don't think we can really trust all this code to produce properly "sanitized" input. Sanitizers are notoriously hard to get right and I see many suspicious places in the Sniffer code.

So if these checks are in place as a measure against accidental errors, they may be useful, but I wouldn't consider them a measure against actual attacks.

Regardless, I put a couple of more specific comments.

Also, we definitely need tests for this.

Comment thread net/http/src/TRootSniffer.cxx
Comment thread net/http/src/TRootSniffer.cxx
Comment thread net/http/src/TRootSniffer.cxx
Comment thread net/httpsniff/inc/TRootSnifferFull.h Outdated
Comment thread net/httpsniff/src/TRootSnifferFull.cxx Outdated
Comment thread net/httpsniff/src/TRootSnifferFull.cxx Outdated
Comment thread net/httpsniff/src/TRootSnifferFull.cxx Outdated
@linev linev force-pushed the http_sanity_arg branch 2 times, most recently from 83b7d75 to 2b46cab Compare May 8, 2026 14:44
@linev linev force-pushed the http_sanity_arg branch from cc20b42 to fa53f87 Compare May 18, 2026 11:18
@linev linev requested a review from bellenot as a code owner May 18, 2026 15:55
@linev linev requested a review from silverweed May 18, 2026 15:59
@linev linev force-pushed the http_sanity_arg branch 3 times, most recently from 69ba55a to c4d0d1f Compare May 19, 2026 11:01
Comment thread net/httpsniff/test/test_sniffer.cxx
@linev linev force-pushed the http_sanity_arg branch from c4d0d1f to ab58efa Compare May 19, 2026 11:24
linev added 6 commits May 20, 2026 09:27
Remove any special symbols
Add escape characters for quote and escape itself
Discard all URL options longer than 1K

Try to avoid manipulation of arguments for method execution
Avoid special characters as draw arguments
Always use DecodeUrlOptionValue method when processing URL arguments
or URL string. Internally method provides escape symbols for quotes and backslash.
If expecting numeric value - remove all symbols
keeping alphanumeric, '.', '+', '-' and ':'
It allows to deserialize post data as ROOT object when processing exe.json request.
While this can leads to arbitrary code loading and injection, disable this feature by default.
Can be enabled back with:
 ```
serv->SetAllowPostObject(kTRUE);
```
While here arbitrary string injected into ProcessLine,
ensure that only numeric argument is not quoted.
All other arguments kinds will be quoted and prevent execution of potentially dangerous code
Verify execution of several supported requests
which can be handled by http server. Testing:
   - root.json
   - root.xml
   - file.root
   - exe.json
   - exe.json with POST data
   - item.json
   - cmd.json
   - multi.json

Also verify basic functionality of
TRootSniffer::DecodeUrlOptionValue method
@linev linev force-pushed the http_sanity_arg branch from ab58efa to 0031f7a Compare May 20, 2026 07:35
@linev linev merged commit 7b34cba into root-project:master May 20, 2026
25 of 30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants